package com.ee.chat.admin.controller.operatemanage;

import com.ee.chat.admin.service.IKeyWordService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author AppiJ
 * @Date 2020/4/23 13:39
 */
@RestController
@RequestMapping("keyWord")
public class KeyWordController {
    private Logger log = LoggerFactory.getLogger(KeyWordController.class);

    @Resource
    IKeyWordService keyWordService;

    /**
     * 获取关键词列表
     * @Author AppiJ
     * @Date 2020/4/23 14:09
     * @param
     * @return
     */
    @RequestMapping("list")
    public Result list(HttpServletRequest request, String word, Integer status, String createTime,
                       @RequestParam Integer page, @RequestParam Integer limit){
        try{
            return keyWordService.list(request, word, status, createTime, page, limit);
        }catch (Exception e){
            log.error("【获取关键词列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 添加关键词
     * @Author AppiJ
     * @Date 2020/4/23 15:01
     * @param
     * @return
     */
    @RequestMapping("add")
    public Result add(HttpServletRequest request, @RequestParam String word){
        try{
            return keyWordService.add(request, word);
        }catch (Exception e){
            log.error("【添加关键词错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 修改关键词状态
     * @Author AppiJ
     * @Date 2020/4/23 15:29
     * @param
     * @return
     */
    @RequestMapping("updateStatus")
    public Result updateStatus(HttpServletRequest request, @RequestParam Integer id){
        try{
            return keyWordService.updateStatus(request, id);
        }catch (Exception e){
            log.error("【修改关键词状态错误】", e);
        }
        return Result.returnFailure();
    }

}
